package flater.cairngormtips
{
import flash.events.Event;

import flater.cairngormtips.controller.CairngormTipsFrontController;
import flater.cairngormtips.controller.events.AnnounceFaultEventExampleEvent;

import mx.core.Application;
import mx.events.FlexEvent;

/**
 *  AnnounceFaultEventExampleApplication is a sample of how the 
 *  AnnounceFaultEvent behaves 
 *  in the UM Cairngorm Extentions. <br/>
 *  <br/>
 *  To begin understanding the pattern, review the mappings in 
 *  CairngormTipsFrontController.
 *  Then, trace the path of...<br/>
 *  <br/>
 *     &nbsp;&nbsp;&nbsp;&nbsp;AnnounceFaultEventExampleEvent<br/>
 *     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to<br/>
 *     &nbsp;&nbsp;&nbsp;&nbsp;AnnounceFaultEventExampleCommand<br/>                                                     
 *     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to<br/>
 *     &nbsp;&nbsp;&nbsp;&nbsp;AnnounceFaultEventExampleDelegate<br/>                                                    
 *     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to<br/>
 *     &nbsp;&nbsp;&nbsp;&nbsp;The UM Command class (which dispatches 
 *     AnnounceFaultEvent)<br/>                           
 *     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;to<br/>
 *     &nbsp;&nbsp;&nbsp;&nbsp;FaultCommand<br/>                                                                         
 *  <br/>                                                                                            
 *  Author: <a href="http://www.adamflater.net" target="_blank">Adam Flater</a>
 *  <br/>                                                                                          
 *  @see com.universalmind.cairngorm.commands.Command                                        
 *  @see com.universalmind.cairngorm.events.AnnounceFaultEvent                             
 *  @see flater.cairngormtips.controller.CairngormTipsFrontController                        
 *  @see flater.cairngormtips.controller.events.AnnounceFaultEventExampleEvent               
 *  @see flater.cairngormtips.controller.commands.AnnounceFaultEventExampleCommand           
 *  @see flater.cairngormtips.controller.commands.FaultCommand                              
 *  @see flater.cairngormtips.controller.delegates.AnnounceFaultEventExampleDelegate
 */	
public class AnnounceFaultEventExampleApplication extends Application
{
	/**
	 *  @protected
	 * 
	 *  Need to keep a reference to the FrontController so that is 
	 *  not garbage collected. CairngormTipsFrontController maps the 
	 *  Cairngorm Events used in the sample to the appropriate 
	 *  Cairngorm Commands.
	 */
	protected static var cairngormTipsFrontController : 
	   CairngormTipsFrontController = null;

	/**
	 *  Constructor.
	 */
	public function AnnounceFaultEventExampleApplication()
	{
		super();
		
		if ( cairngormTipsFrontController == null )
		{
            cairngormTipsFrontController = 
                new CairngormTipsFrontController();
		}
		
		this.addEventListener( FlexEvent.CREATION_COMPLETE, 
		                       handleCreationComplete );
	}
	
    /**
     *  @private
     * 
     *  Event handler; responds to creationComplete by dispatching
     *  the AnnounceFaultEventExampleEvent.
     */
    private function handleCreationComplete( e : Event ) : void
    {
        var event : AnnounceFaultEventExampleEvent = 
                new AnnounceFaultEventExampleEvent();
            event.dispatch();
    }
    
} //  end class
} //  end package